package org.footito.android.dialog;

import java.util.ArrayList;

import org.footito.android.R;
import org.footito.android.data.Group;
import org.footito.android.data.Subscriber;

import android.app.Dialog;
import android.content.Context;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class SubscribersDialogs extends Dialog {

	private ListView list;

	public SubscribersDialogs(Context context, Group current) {
		super(context);
		setContentView(R.layout.subs);
		list = (ListView) findViewById(R.id.list);

		ArrayList<Subscriber> subs = current.getSubscribers();

		if (subs.size() > 0) {
			String[] teams = new String[subs.size()];
			for (int i = 0; i < subs.size(); i++) {
				teams[i] = subs.get(i).getTeam().getName();
			}
			list.setAdapter(new ArrayAdapter<String>(context, R.layout.row_sub, R.id.TV_Subscriber, teams));
		} else {
			String[] message = { context.getResources().getString(R.string.no_subscriber) };
			list.setAdapter(new ArrayAdapter<String>(context, R.layout.row_sub, R.id.TV_Subscriber, message));
		}
		this.setTitle("Ont rejoins le groupe");
	}

}
